/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.loja.view.component.aggregation;

import br.com.loja.view.component.factory.ViewHadler;
import javax.swing.JComboBox;

/**
 *
 * @author DavidLuiz
 */
public class EnumToOne<T> extends JComboBox<T> implements ViewHadler<T> {

    private Class<T> clazz;

    public EnumToOne(Class<T> clazz) {
        super(clazz.getEnumConstants());
    }

    @Override
    public void setValueModel(T value) {
        getModel().setSelectedItem(value);
        updateUI();
    }

    @Override
    public T getValueModel() {
        return (T) getModel().getSelectedItem();
    }

}
